package com.zl.Sqlite.db;

import android.test.AndroidTestCase;
import com.zl.Sqlite.DBheloper;

/**
 * User: c3t
 * Date: 14-5-1
 * Time: 下午4:00
 */
public class TestDb extends AndroidTestCase {


    public void testCreateDB() {

        DBheloper dBheloper = DBheloper.getInstance(getContext());
        dBheloper.getWritableDatabase();
    }

    public void testAdd() throws Exception {

        UserDao userDao = new UserDao(getContext());
        userDao.add("zhaoliu");
        assertEquals(true, userDao.find("zhaoliu"));
    }

    public void testFindAll() throws Exception {
        UserDao userDao = new UserDao(getContext());
        for(User u : userDao.findAll()) {

            System.out.println(u.getName());
        }
    }

    public void testUpdate() throws Exception {

        UserDao userDao = new UserDao(getContext());
        userDao.update("wangwu", 1);
        System.out.println(userDao.findAll().get(0).getName());
    }

    public void testDelete() throws Exception{

        UserDao userDao = new UserDao(getContext());
        userDao.delete(1);
        assertEquals(false, userDao.find("wangwu"));
    }
}
